Advanced Animation with DirectX by Jim Adams
Author:Jim Adams [Adams, Jim]
Language: eng
Format: epub, pdf
Published: 2003-11-24T23:00:53+00:00
Setting the Forces
}
if(vecSize−>y < MINIMUM_BONE_SIZE) {
vecSize−>y = MINIMUM_BONE_SIZE;
vecMax.y = MINIMUM_BONE_SIZE*0.5f;
}
if(vecSize−>z < MINIMUM_BONE_SIZE) {
vecSize−>z = MINIMUM_BONE_SIZE;
vecMax.z = MINIMUM_BONE_SIZE*0.5f;
}
// Set the bone's offset to center based on half the size
// of the bounding box and the max position
(*vecJointOffset) = ((*vecSize) * 0.5f) − vecMax;
}
At the very end of the function, you finally encounter the vecJointOffset vector object that I mentioned when you started creating the GetBoundingBoxSize function. Because a rigid body bone can be any size, and you track the bone by its center coordinates, you need to create an extra point that represents the point in the bounding box where the bone connects to its parent. This is the joint offset vector. You'll read more about the joint offset vector when you enforce the bone−to−bone connections.
Now that you've computed the bounding−box size and set the various bones' data, you can set the various forces and resolve the motion of your bones.
Setting the Forces
For any applied forces you want to use (which I'll leave up to you), you must handle gravity and damping. In the cRagdoll class, I defined a function that clears out a single bone's force and torque vectors and then applies gravity and damping forces.
void cRagdoll::SetForces(DWORD BoneNum,
D3DXVECTOR3 *vecGravity,
float LinearDamping,
float AngularDamping)
{
// Get a pointer to the bone for easier handling
cRagdollBone *Bone = &m_Bones[BoneNum];
// Get pointer to the current state for easier handling
cRagdollBoneState *BCState = &Bone−>m_State;
// Set gravity and clear torque
Bone−>m_vecForce = ((*vecGravity) * Bone−>m_Mass);
Bone−>m_vecTorque = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
// Apply damping on force and torque
Bone−>m_vecForce += (BCState−>m_vecLinearVelocity * \
LinearDamping);
Bone−>m_vecTorque += (BCState−>m_vecAngularVelocity * \
AngularDamping);
}
You read about gravity and damping forces earlier in this chapter, so I shouldn't need to explain anything here. You'll notice that I'm scaling the gravity vector by the mass of the bone. Remember that this is necessary so that gravity will pull all objects with the same force when you later scale the forces due to mass.
169
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Personalized inhaled bacteriophage therapy for treatment of multidrug-resistant Pseudomonas aeruginosa in cystic fibrosis by unknow(183502)
CONSORT 2025 statement: updated guideline for reporting randomized trials by unknow(91801)
Critical evaluation of the ProfiLER-02 study design and outcomes by Vivek Subbiah & Razelle Kurzrock(91505)
Cardiac gene therapy makes a comeback by Oliver J. Müller & Susanne Hille & Anca Kliesow Remes(91191)
Whisky: Malt Whiskies of Scotland (Collins Little Books) by dominic roskrow(74468)
Unveiling the design rules for tunable emission in graphene quantum dots: A high-throughput TDDFT and machine learning perspective by Şener Özönder & Mustafa Coşkun Özdemir & Caner Ünlü(50912)
A yeast-based oral therapeutic delivers immune checkpoint inhibitors to reduce intestinal tumor burden by unknow(40287)
Covalent hitchhikers guide proteins to the nucleus by Alexander F. Russell & Madeline F. Currie & Champak Chatterjee(40227)
Meet the Authors: Christopher R. Mansfield and Emily R. Derbyshire by Christopher R. Mansfield & Emily R. Derbyshire(40113)
Alkaline-earth metals promote propane dehydrogenation with carbon dioxide through geometric effects: Altering the reaction pathway by unknow(32754)
Induced iron vacancies boosting FeOOH loaded on sustainable Fenton-like collagen fiber membrane for efficient removal of emerging contaminants by unknow(32538)
Efficient electric-field-assisted photochemical conversion of methane to n-propanol exclusively over penetrated TiO2Ti hollow fibers by Guanghui Feng(32472)
Bi2SiO5 nanosheets as piezo-photocatalyst for efficient degradation of 2,4-Dichlorophenol by Hangyu Shi & Yifu Li & Lishan Zhang & Guoguan Liu & Qian Zhang & Xuan Ru & Shan Zhong(32408)
A novel NDIPTA organic heterojunction photocatalyst with built-in electric field for efficient hydrogen production by Jiahui Yang & Baojun Ma & Yongfa Zhu(32381)
Enhanced conversion of methane to liquid-phase oxygenates via hollow ferrite nanotube@horseradish peroxidase based photoenzymatic catalysis by Jun Duan & Shiying Fan & Xinyong Li & Shaomin Liu(32348)
Ordered macroporous superstructure of defective carbon adorned with tiny cobalt sulfide for selective electrocatalytic hydrogenation of cinnamaldehyde by Xiao-Shi Yuan & Sheng-Hua Zhou & San-Mei Wang & Wenbo Wei & Xiaofang Li & Xin-Tao Wu & Qi-Long Zhu(32269)
What's Done in Darkness by Kayla Perrin(27163)
Topological analysis of non-conjugated ethylene oxide cored dendrimers decorated with tetraphenylethylene: Insights from degree-based descriptors using the polynomial approach by A Theertha Nair & D Antony Xavier & Annmaria Baby & S Akhila(26553)
Investigation of mechanical and self-healing properties of hydroxyl-terminated polybutadiene functionalized with 2-ureido-4-pyrimidinone by Mohsen Kazazi & Mehran Hayaty & Ali Mousaviazar(26486)